<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head th:replace="common/header :: common_head(~{::title},~{::meta},~{::link},~{})">
    <title >知文原创小说网站</title>
    <meta name="keywords" content="知文小说网,小说,小说CMS,原创文学系统,开源小说系统,免费小说建站程序"/>
    <meta name="description"
          content="知文小说网是一个功能完善的原创文学CMS系统，由前台门户系统、作家后台管理系统、平台后台管理系统
          、爬虫管理系统等多个子系统构成，支持会员充值、订阅模式、新闻发布和实时统计报表等功能，新书自动入库，老书自动更新。"/>
    <link href="favicon.ico" type="image/x-icon" rel="shortcut icon"/>
    <link href="favicon.ico" type="image/x-icon" rel="Bookmark"/>
    <link rel="stylesheet" href="/css/main.css"/>
<!--</head>-->
<body>


<div th:replace="common/top :: top('0')">
</div>
<div id="app">
<div class="main box_center cf">
    <div class="channelWrap channelBanner cf">
        <div class="leftBox">
            <div class="sliderContent" >
                    <dl class="scBigImg" id="carouseBig" v-if="bookMap['0']">
                        <dd v-for="(book, index) in bookMap['0']" :key="index" :class="{ 'on': currentIndex  === index }">
                            <a :href="'/book/' + book.bookId + '.html'">
                                <img :src="book.picUrl" :alt="book.bookName" />
                            </a>
                        </dd>
                    </dl>
                    <div class="scSmallImg" id="carouseSmall" v-if="bookMap['0']">
                        <ul>
                            <li v-for="(book, index) in bookMap['0']" @mouseenter="changeSlide(index)" :key="index" :class="{ 'on':  currentIndex === index }">
                                <img :src="book.picUrl" :alt="book.bookName" />
                            </li>
                        </ul>
                    </div>
            </div>
            <div class="hot_articles">

                <template v-if="bookMap['1'] && bookMap['1'].length > 0">
                    <dl class="hot_recommend" id="topBooks1">
                        <dt>
                            <a :href="'/book/' + bookMap['1'][0].bookId + '.html'" v-text="bookMap['1'][0].bookName"></a>
                        </dt>
                        <dd v-if="bookMap['1'].length > 1">
                            <a :href="'/book/' + bookMap['1'][1].bookId + '.html'" v-text="bookMap['1'][1].bookName"></a>
                            <a v-if="bookMap['1'].length > 2" :href="'/book/' + bookMap['1'][2].bookId + '.html'" v-text="bookMap['1'][2].bookName"></a>
                        </dd>
                        <dd v-if="bookMap['1'].length > 3">
                            <a :href="'/book/' + bookMap['1'][3].bookId + '.html'" v-text="bookMap['1'][3].bookName"></a>
                            <a v-if="bookMap['1'].length > 4" :href="'/book/' + bookMap['1'][4].bookId + '.html'" v-text="bookMap['1'][4].bookName"></a>
                        </dd>
                    </dl>
                </template>

                <template v-if="bookMap['1'] && bookMap['1'].length > 5">
                    <dl class="hot_recommend" id="topBooks2">
                        <dt>
                            <a :href="'/book/' + bookMap['1'][5].bookId + '.html'" v-text="bookMap['1'][5].bookName"></a>
                        </dt>
                        <dd v-if="bookMap['1'].length > 6">
                            <a :href="'/book/' + bookMap['1'][6].bookId + '.html'" v-text="bookMap['1'][6].bookName"></a>
                            <a v-if="bookMap['1'].length > 7" :href="'/book/' + bookMap['1'][7].bookId + '.html'" v-text="bookMap['1'][7].bookName"></a>
                        </dd>
                        <dd v-if="bookMap['1'].length > 8">
                            <a :href="'/book/' + bookMap['1'][8].bookId + '.html'" v-text="bookMap['1'][8].bookName"></a>
                            <a v-if="bookMap['1'].length > 9" :href="'/book/' + bookMap['1'][9].bookId + '.html'" v-text="bookMap['1'][9].bookName"></a>
                        </dd>
                    </dl>
                </template>


<!--                <dl class="hot_notice" id="indexNews">-->
<!--                    <dd v-for="(news, index) in newsList" :key="index" >-->
<!--                        <span >{{news.catName}}</span>-->
<!--                        <a :href="'/about/newsInfo-'+news.id+'.html'" :utext="news.title">-->
<!--                        </a>-->
<!--                    </dd>-->
<!--&lt;!&ndash;                    <dd style="text-align:left;" th:each="news : ${newsList}"><span th:text="'['+${news.catName}+']'"></span><a th:href="'/about/newsInfo-'+${news.id}+'.html'" th:utext="${news.title}"></a>&ndash;&gt;-->
<!--&lt;!&ndash;                    </dd>&ndash;&gt;-->
<!--                </dl>-->
                <dl class="hot_notice" id="indexNews">
                    <dd v-for="(news, index) in newsList" :key="index" style="text-align:left;">
                        <span>[{{ news.catName }}]</span>
                        <a :href="'/about/newsInfo-' + news.id + '.html'" v-html="news.title"></a>
                    </dd>
                </dl>
            </div>
        </div>
        <div class="rightBox">
            <div class="title cf" id="weekcommend">
                <h3>本周强推</h3>
            </div>
            <div class="rightList">
                <ul id="currentWeek" v-if="bookMap['2']">
                    <li v-for="(book, index) in bookMap['2']" :key="book.bookId" :class="{'on num1': index === 0, ['num' + (index + 1)]: index < 3}">
                        <div class="book_name"><i>{{ index + 1 }}</i><a class="name" :href="'/book/' + book.bookId + '.html'">{{ book.bookName }}</a></div>
                        <div class="book_intro">
                            <div class="cover"><a :href="'/book/' + book.bookId + '.html'"><img :src="book.picUrl" :alt="book.bookName"></a></div>
                            <a class="txt" :href="'/book/' + book.bookId + '.html'" v-html="book.bookDesc"></a>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>

    <div class="channelWrap channelPic cf">
        <div class="leftBox">
            <div class="title">
                <h2 class="on">热门推荐</h2>
            </div>
            <div class="picRecommend cf" id="hotRecBooks" v-if="bookMap['3']">
                <div class="itemsList" v-for="book in bookMap['3']">
                    <a class="items_img" :href="'/book/'+book.bookId+'.html'">
                        <img class="lazyload" src="/images/default.gif" :src="book.picUrl" :alt="book.bookName">
                    </a>
                    <div class="items_txt">
                        <h4><a :href="'/book/'+book.bookId+'.html'">{{book.bookName}}</a></h4>
                        <p class="author"><a href="javascript:void(0)" >作者:{{book.authorName}}</a></p>
                        <p class="intro"><a href="'/book/'+book.bookId+'.html'" v-html="book.bookDesc"></a>
                        </p>
                    </div>
                </div>

            </div>
        </div>
        <div id="bookrank1_ShowBookRank">
            <div class="rightBox ">
                <div class="title cf">
                    <h3 class="on">点击榜单</h3>
                </div>
                <div class="rightList">
                            <ul id="clickRankBooks">
                                <li v-for="(clickRankBook, index) in clickRankBooks" :key="index" :class="{'on num1': index === 0, ['num' + (index + 1)]: index < 3}">
                                    <div class="book_name">
                                        <i>{{ index + 1 }}</i><a class="name" :href="'/book/'+clickRankBook.id+'.html'">{{ clickRankBook.bookName }}</a>
                                    </div>
                                    <div class="book_intro">
                                        <div class="cover">
                                            <a :href="'/book/'+clickRankBook.id+'.html'"><img :src="clickRankBook.picUrl" alt="Book Cover"></a>
                                        </div>
                                        <a class="txt" :href="'/book/'+clickRankBook.id+'.html'">{{ clickRankBook.bookDesc }}</a>
                                    </div>

                                </li>
                            </ul>
                    <div class="more"><a href="/book/book_ranking.html">查看更多&gt;</a></div>
                </div>
            </div>
        </div>
    </div>
    <div class="channelWrap channelPic cf">
        <div class="leftBox">
            <div class="title">
                <h2>精品推荐</h2>
            </div>
            <div class="picRecommend cf" v-if="bookMap['4']">
                <div class="itemsList" v-for="book in bookMap['4']" :key="book.bookId">
                    <a class="items_img" :href="'/book/' + book.bookId + '.html'">
                        <img class="lazyload" src="/images/default.gif" :src="book.picUrl" :alt="book.bookName">
                    </a>
                    <div class="items_txt">
                        <h4><a :href="'/book/' + book.bookId + '.html'" v-text="book.bookName"></a></h4>
                        <p class="author"><a href="javascript:void(0)" v-text="'作者：' + book.authorName"></a></p>
                        <p class="intro"><a :href="'/book/' + book.bookId + '.html'" v-html="book.bookDesc"></a></p>
                    </div>
                </div>
            </div>
        </div>
        <div id="bookrank2_ShowBookRank">
            <div class="rightBox ">
                <div class="title cf">
                    <h3 class="on">新书榜单</h3>
                </div>
                <div class="rightList">
                    <ul id="newRankBooks" v-if="newRankBooks">
                        <li v-for="(newRankBook, index) in newRankBooks" :key="index" :class="{'on num1': index === 0, ['num' + (index + 1)]: index < 3 }">
                            <div class="book_name">
                                <i>{{ index + 1 }}</i><a class="name" :href="'/book/'+newRankBook.id+'.html'">{{ newRankBook.bookName }}</a>
                            </div>
                            <div class="book_intro">
                                <div class="cover">
                                    <a :href="'/book/'+newRankBook.id+'.html'"><img :src="newRankBook.picUrl" alt="Book Cover"></a>
                                </div>
                                <a class="txt" :href="'/book/'+newRankBook.id+'.html'" v-html="newRankBook.bookDesc"></a>
                            </div>

                        </li>

                    </ul>
                    <div class="more"><a href="/book/book_ranking.html?type=1">查看更多&gt;</a></div>
                </div>
            </div>
        </div>
    </div>
    <div class="channelWrap channelTable cf">
        <div class="leftBox">
            <div class="title">
                <h2>最新更新</h2>
            </div>
            <div class="updateTable">
                <table cellpadding="0" cellspacing="0">
                    <thead>
                    <tr>
                        <th class="style">类别</th>
                        <th class="name">书名</th>
                        <th class="chapter">最新章节</th>
                        <th class="author">作者</th>
                        <th class="time">更新时间</th>
                    </tr>
                    </thead>
                    <tbody id="newRankBooks2">
                    <tr v-for="(updateRankBook, index) in updateRankBooks" :key="index" >
                        <td class="style"><a :href="'/book/bookclass.html?c='+updateRankBook.catId">[{{ updateRankBook.catName }}]</a></td>
                        <td class="name"><a :href="'/book/'+updateRankBook.id+'.html'">{{ updateRankBook.bookName }}</a></td>
                        <td class="chapter"><a :href="'/book/'+updateRankBook.id+'.html'">{{ updateRankBook.lastIndexName }}</a>
                            <i class=""></i>
                        </td>
                        <td class=\"author\"><a href=\"javascript:void(0)\"> {{updateRankBook.authorName}} </a></td> +
                        <td class=\"time\"> {{updateRankBook.lastIndexUpdateTime}} </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <div id="bookrank5_ShowBookRank">
            <div class="rightBox mb20">
                <div class="title cf">
                    <h3 class="on">更新榜单</h3>
                </div>
                <div class="rightList">
                    <ul id="updateRankBooks"><li   v-for="(updateRankBook, index) in updateRankBooks" :key="index" v-if="index < 10" :class="{'on num1': index === 0, ['num' + (index + 1)]: index < 3 }">
                        <div class="book_name">
                            <i>{{ index + 1 }}</i><a class="name" :href="'/book/'+updateRankBook.id+'.html'">{{ updateRankBook.bookName }}</a>
                        </div>
                        <div class="book_intro">
                            <div class="cover">
                                <a :href="'/book/'+updateRankBook.id+'.html'"><img :src="updateRankBook.picUrl" alt="Book Cover"></a>
                            </div>
                            <a class="txt" :href="'/book/'+updateRankBook.id+'.html'" v-html=" updateRankBook.bookDesc "></a>
                        </div>
                    </li>

                    </ul>
                    <div class="more"><a href="/book/book_ranking.html?type=2">查看更多&gt;</a></div>
                </div>
            </div>
        </div>

    </div>
</div>
<div class="friend_link">
    <div class="box_center cf" id="friendLink">
        <span>友情链接：</span>
    </div>
</div>

<div th:replace="common/footer :: footer">
</div>

</div>
</body>
<div th:replace="common/js :: js"></div>
<script src="/javascript/lazyload.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

    let app= new Vue({
        el:"#app",

        data(){
            return{
                bookMap:[],
                clickRankBooks:[],
                newRankBooks:[],
                updateRankBooks:[],
                currentIndex: 0, // Current index of the active slide
                timer: null,
                newsList:[]
            };
        },
        mounted() {
            //获得首页的基础数据
            axios.get("/indexcache").then(res=>{
                this.bookMap = res.data;
            })
            axios.get("/newList").then(res=>{
                this.newsList = res.data;
            })
            this.fetchClickRankData();
            this.fetchNewRankData();
            this.fetchUpdateData();
            this.startAutoSlide();
        },
        methods:{
            fetchClickRankData() {
                //获取点击榜
                axios.get('/book/listClickRank')
                    .then(response => {
                        if (response.data.code === "200") {
                            this.clickRankBooks = response.data.data;
                        } else {
                            this.showAlert(response.data.msg);
                        }
                    })
                    .catch(error => {
                        console.error('网络错误', error);
                        this.showAlert('网络错误', error);
                    });
            },
            fetchNewRankData() {
                //获取新书榜
                axios.get('/book/listNewRank')
                    .then(response => {
                        if (response.data.code === "200") {
                            this.newRankBooks = response.data.data;
                        } else {
                            this.showAlert(response.data.msg);
                        }
                    })
                    .catch(error => {
                        console.error('网络错误', error);
                        this.showAlert('网络错误', error);
                    });
            },
            fetchUpdateData() {
                //获取更新榜
                axios.get('/book/listUpdateRank')
                    .then(response => {
                        if (response.data.code === "200") {
                            this.updateRankBooks = response.data.data;
                        } else {
                            this.showAlert(response.data.msg);
                        }
                    })
                    .catch(error => {
                        console.error('网络错误', error);
                        this.showAlert('网络错误', error);
                    });
            },
            getClass(index) {
                // Implement your logic for determining class dynamically based on index
                // Return the appropriate class for the item
            },
            showAlert(message) {
                // Implement your alert mechanism here
            },
            //轮播效果
            changeSlide(index) {
                // Change the active slide
                this.currentIndex = index;
                // Reset automatic sliding timer
                this.resetAutoSlide();
            },
            startAutoSlide() {
                // Start automatic sliding
                this.timer = setInterval(() => {
                    this.currentIndex = (this.currentIndex + 1) % this.bookMap[0].length;
                }, 3000);
            },
            resetAutoSlide() {
                // Reset automatic sliding timer
                clearInterval(this.timer);
                this.startAutoSlide();
            }

        }

    })
    // var $div = $('.scBigImg dl');//放置大图容器
    // var $nav = $('.scSmallImg li');//放置缩略图容器
    // var num = -1;
    // var open;
    //
    // function changeKv() {
    //     if (num >= $nav.length - 1) {
    //         num = 0;
    //     } else {
    //         num++;
    //     }
    //     $nav.eq(num).trigger('mouseenter');
    //     open = setTimeout(changeKv, 3000);
    // }
    //
    // changeKv();
    // $nav.each(function (index) {
    //     $(this).off('mouseenter').on('mouseenter', function () {
    //         clearTimeout(open);
    //
    //         $(this).addClass('on').siblings().removeClass('on');
    //         $('.scBigImg dd').eq(index).addClass('on').siblings().removeClass('on');
    //         $('.scSmallImg').off('mouseleave').on('mouseleave', function () {
    //             num = index;
    //             setTimeout(function () {
    //                 changeKv();
    //             }, 3000)
    //         })
    //     });
    // });
    // $div.each(function () {
    //     $(this).off('mouseenter').on('mouseenter', function () {
    //         clearTimeout(open);
    //     });
    // });

    lazyload();
    $("#weekcommend h3").mouseover(function () {
        $("#weekcommend h3").removeClass("on");
        $(this).addClass("on");
        if ($(this).attr("class").indexOf("fr") >= 0) {
            $("#currentWeek").hide();
            $("#currentPreWeek").show();
        } else {
            $("#currentPreWeek").hide();
            $("#currentWeek").show();
        }
    });



 </script>
</html>